package org.ix.boot.app;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;

public class MainTest {

    public static void main(String[] args) throws LifecycleException {
        Tomcat tomcat = new Tomcat();
        Connector connector = new Connector();
        connector.setPort(8088);
        connector.setURIEncoding("UTF-8");
        tomcat.getService().addConnector(connector);

        /*
        web.xml url-mapping 或者 @WebServlet
         */
        HomeServlet homeServlet = new HomeServlet();
        Context context = tomcat.addContext("/", null);
        tomcat.addServlet(context, "homeServlet", homeServlet);
        context.addServletMappingDecoded("/home.do", "homeServlet");

        tomcat.start();
        tomcat.getServer().await();
    }
}
